package user.controller;

import core.controller.BaseController;
import core.domain.ListDataInfo;
import core.domain.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import user.domain.question.dto.QuestionQueryDTO;
import user.domain.question.vo.QuestionDetailVO;
import user.domain.question.vo.RankVO;
import user.service.IQuestionService;

@RestController
@Slf4j
@RequestMapping("/question")
public class QuestionController extends BaseController {

    @Autowired
    private IQuestionService questionService;
    @GetMapping("/semiLogin/list")
    public ListDataInfo list(QuestionQueryDTO questionQueryDTO) {
        log.info("C -> QuestionController -> list, {}", questionQueryDTO);
        return questionService.list(questionQueryDTO);
    }

    @GetMapping("/detail")
    public Result<QuestionDetailVO> detail(Long questionId){
        log.info("C -> QuestionController -> detail, {}", questionId);
        return Result.success(questionService.detail(questionId));
    }

    @GetMapping("/preQuestion")
    public Result<String> preQuestion(Long questionId){
        log.info("C -> QuestionController -> preQuestion, {}", questionId);
        return Result.success(questionService.preQuestion(questionId));
    }

    @GetMapping("/nextQuestion")
    public Result<String> nextQuestion(Long questionId) {
        log.info("C -> QuestionController -> nextQuestion, {}", questionId);
        return Result.success(questionService.nextQuestion(questionId));
    }

    @GetMapping("/semiLogin/topRank")
    public ListDataInfo topRank(){
        log.info("C -> QuestionController -> topRank");
        return toListDataInfo(questionService.topRank());
    }
}
